class Student2:
    def __init__(self, name, sex, age, score):
        self.name = name
        self.sex = sex
        self.age = age
        self.score = score

    def print_self(self):
        print(self.name, self.sex, self.age, self.score)


def get_obj_from_name(list_target, search_name):
    for obj in list_target:
        if search_name == obj.name:
            return obj


def get_objs_by_sex(list_target, sex):
    return [obj for obj in list_target if obj.sex == sex]


def get_objs_by_age_and_score(list_target, age, score):
    """
        根据年龄和成绩查找
    :param list_target: 要查找的列表
    :param age: 年龄(大于>)
    :param score: 成绩(大于>)
    :return: 符合的对象列表
    """
    return [obj for obj in list_target if obj.age > age and obj.score > score]


def list_obj_print(list_target):
    for obj in list_target:
        obj.print_self()


s1 = Student2('黄蓉', '女', 18, 89)
s2 = Student2('欧阳锋', '男', 38, 97)
s3 = Student2('黄药师', '男', 48, 99)
s4 = Student2('郭靖', '男', 18, 79)

list_hero = [s1, s2, s3, s4]

get_obj_from_name(list_hero, '郭靖').print_self()
list_girl = get_objs_by_sex(list_hero, '女')
list_obj_print(list_girl)
list_obj_print(get_objs_by_age_and_score(list_hero, 30, 60))
